package com.ruoyi.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @author nanyang
 */
public class TFlupInfoVo {

    @Data
    @ApiModel("TFlupInfoVo")
    public static class Result {
        @ApiModelProperty("id")
        private Long id;
        @Excel(name = "档案号")
        @ApiModelProperty("档案号")
        private String fileNum;
        @ApiModelProperty("身份证号")
        @Excel(name = "身份证号")
        private String idcard;
        @ApiModelProperty("姓名")
        @Excel(name = "姓名")
        private String name;
        @ApiModelProperty("性别")
        @Excel(name = "性别")
        private Byte sex;
        @ApiModelProperty("年龄")
        @Excel(name = "年龄")
        private Integer age;
        @ApiModelProperty("住院时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @Excel(name = "住院时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
        private Date enterTime;
        @ApiModelProperty("出院时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @Excel(name = "出院时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
        private Date leaveTime;
        @ApiModelProperty("危险分级")
        @Excel(name = "危险分级")
        private Byte riskLevel;
        @ApiModelProperty("治疗类型(多选，值用逗号隔开)")
        @Excel(name = "治疗类型")
        private String treatmentType = "";
        @ApiModelProperty("随访轮次")
        @Excel(name = "随访轮次")
        private Byte round;
        @ApiModelProperty("随访时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        @Excel(name = "随访时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
        private Date flupTime;
        @ApiModelProperty("随访方式")
        @Excel(name = "随访方式")
        private Byte flupMode;
        @ApiModelProperty("婚姻状况")
        @Excel(name = "婚姻状况")
        private Byte maritalStatus;
        @ApiModelProperty("医疗付费方式")
        @Excel(name = "医疗付费方式")
        private Byte payMode;
        @ApiModelProperty("受教育程度")
        @Excel(name = "受教育程度")
        private Byte educationLevel;
        @ApiModelProperty("联系人姓名")
        @Excel(name = "联系人姓名")
        private String contactName;
        @ApiModelProperty("电话1")
        @Excel(name = "联系人电话")
        private String firstPhone;
        @ApiModelProperty("电话2")
        private String secondPhone;
        @ApiModelProperty("电话3")
        private String thirdPhone;
        @ApiModelProperty("出院科别")
        @Excel(name = "出院科别")
        private String leaveDepartment;
        @ApiModelProperty("居住详细地址")
        @Excel(name = "居住详细地址")
        private String address;
        @ApiModelProperty("是否失访")
        @Excel(name = "是否失访")
        private Byte lostFlupFlag;
        @ApiModelProperty("失访原因")
        @Excel(name = "失访原因")
        private Byte lostFlupReason;
        @ApiModelProperty("是否死亡")
        @Excel(name = "是否死亡")
        private Byte deathFlag;
        @ApiModelProperty("死亡时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        @Excel(name = "死亡时间")
        private Date deathTime;
        @ApiModelProperty("死亡原因")
        @Excel(name = "死亡原因")
        private Byte deathReason;
        @ApiModelProperty("随访状态（0：待随访，1：已随访）")
        @Excel(name = "随访状态")
        private Byte flupFlag;
        @ApiModelProperty("审核状态")
        private Byte auditStatus;
        @ApiModelProperty("数据来源")
        @Excel(name = "数据来源")
        private Byte source;
        @ApiModelProperty("创建人")
        private String createBy;
        @ApiModelProperty("创建时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date createTime;
        @ApiModelProperty("修改人")
        private String updateBy;
        @ApiModelProperty("修改时间")
        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date updateTime;

        public String getDepartmentId(){
            return leaveDepartment;
        }


        public Byte getLostFlupFlag() {

            if (leaveTime == null) {
                return null;
            }
            Long starTime = System.currentTimeMillis();
            Long endTime = leaveTime.getTime();
            Long num = endTime - starTime;//时间戳相差的毫秒数
            Long day = num / 24 / 60 / 60 / 1000;
            if (day > 97) {
                return 0;
            }
            return 1;
        }
    }

    @Data
    @ApiModel("查询随访信息")
    public static class Export {
        @Excel(name = "姓名")
        @ApiModelProperty("姓名")
        private String name;
        @Excel(name = "危险分级")
        @ApiModelProperty("危险分级")
        private Byte riskLevel;
        @Excel(name = "治疗类型")
        @ApiModelProperty("治疗类型")
        private String treatmentType;
        @Excel(name = "随访轮次")
        @ApiModelProperty("随访轮次")
        private Byte round;
        @Excel(name = "住院时间")
        @ApiModelProperty("住院时间")
        private Date enterTimeStart;
        @Excel(name = "住院时间")
        @ApiModelProperty("住院时间")
        private Date enterTimeEnd;
        @Excel(name = "出院时间")
        @ApiModelProperty("出院时间")
        private Date leaveTimeStart;
        @Excel(name = "出院时间")
        @ApiModelProperty("出院时间")
        private Date leaveTimeEnd;
        @Excel(name = "审核状态")
        @ApiModelProperty("审核状态")
        private Byte auditStatus;
        @Excel(name = "是否死亡")
        @ApiModelProperty("是否死亡")
        private Byte deathFlag;
        @Excel(name = "是否失访")
        @ApiModelProperty("是否失访")
        private Byte lostFlupFlag;
        @Excel(name = "数据来源")
        @ApiModelProperty("数据来源")
        private Byte source;
        @ApiModelProperty("随访状态（0：待随访，1：已随访）")
        private Byte flupFlag;
    }
}
